<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>tree edit</title>
    <uieip type="file" value="inc" src="/yqwin/easyui/include.txt" cache="true" minute="1440"></uieip>
    <uieip type="file" value="css" src="/yqwin/css/yqwin.min" cache="false"></uieip>
    <uieip type="file" value="js" src="/yqwin/data/yqwin.min" cache="false"></uieip>
</head>

<body style="margin: 0;">
    <ul id="tt">
    </ul>

    <script>
        $(function () {
            init_tree();
        })

        function init_tree() {
            $('#tt').yqTree({
                ajaxUrl: "/Api/Base/tree.html", //ajax地址
                dbname: "yqbase",   //数据库
                tbname: "tree2",       //表
                keyId: "sid",       //关键字段
                bindingKeyId: null,
                bindingValue: null,
                pKeyId: "pid",
                pKeyValue: null,

                loadDataType: 2,    //全局加载模式
                displayMember: "name",
                loadData: true,

                menuType: 3,  //1-顶部菜单，2-右键菜单，3-顶部+右键  其他，无菜单

                overflowY: true,
                width: 300,
                height: 500,

                editMode: 1,   //1,2-弹出编辑模态窗体
                editType: 1,
                editModeW: 650, //模态编辑器宽度 格式为 800（数字） 
                editModeH: 350, //模态编辑器高度 格式为 600（数字） 
                editModeNo: -1, //编辑模板
                border:true,
                beforeBindingTitle: function (titles, callback) {
                    console.log("beforeBindingTitle", titles);
                    callback(titles);
                }, //标题绑定前
                afterBindingTitle: function () {
                    // 绑定窗口大小改变事件
                    $(window).on('resize', () => onresize());
                    onresize();
                    //---------------
                }, //标题绑定后

                beforeSetdata: function (data, callback) {
                    console.log("beforeSetdata", data);
                    callback(data)
                }, //绑定数据之前
                afterSetdata: function (data) {
                    console.log("afterSetdata", data);
                }, //绑定数据之后
                uppActionState: function (s_node, callback) {     //操作节点状态处理接口
                    console.log("uppActionState", s_node);
                    callback(true);
                },
            });
        }

        function onresize() {
            const width = window.innerWidth;
            const height = window.innerHeight;

            $('#tt').yqTree('resize', {
                width: width,
                height: height
            });
        }

    </script>
</body>

</html>